import utils from "../common/util.js"

export default {

	// 登录
	login(){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl+'/lianghua/login',
				method: 'POST',
				data:{
					
				},
				success: function(res) {
					if(res.data.code === 20000){
						uni.setStorageSync("lianghua_user",res.data.data)
						resolve("ok")
					}else{
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: '网络错误',
						showCancel: false
					});
				}
			})
		})
	},
	
	// 获取vip信息
	getVipInfo(query){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl+'/lianghua/isvip',
				method: 'POST',
				data:{
					...query
				},
				success: function(res) {
					if(res.data.code === 20000){
						uni.setStorageSync("lianghua_vip",res.data.data)
						resolve(res.data.data)
					}else{
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: '网络错误',
						showCancel: false
					});
				}
			})
		})
	},
	
	// 获取买卖点
	getPoint(query){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl+'/lianghua/point',
				method: 'POST',
				data:{
					...query
				},
				success: function(res) {
					if(res.data.code === 20000){
						resolve(res.data.data)
					}else{
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: '网络错误',
						showCancel: false
					});
				}
			})
		})
	},
	
	// 获取所以自选基金信息
	getList(query){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl+'/lianghua/all',
				method: 'POST',
				data:{
					...query
				},
				success: function(res) {
					if(res.data.code === 20000){
						resolve(res.data.data)
					}else{
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: '网络错误',
						showCancel: false
					});
				}
			})
		})
	}
		
}